﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace TomNet.Attributes
{
    /// <summary>
    /// 全角字符串
    /// </summary>
    public class SBCAttribute : BaseAttribute
    {
        public override string Error
        {
            get
            {
                if (base.Error != null)
                {
                    return base.Error;
                }
                return "必须为全角字符串";
            }

            set => base.Error = value;
        }
        public override bool Validate(object value)
        {
            var regex = new Regex(@"^[^\\x00-\\xff|^\\uff61-\\uff9f]*$");
            return value == null || regex.Match(value.ToString()).Success;
        }
    }
}
